//
//  SSWBComposeTypeButton.swift
//  shanshanlol微博
//
//  Created by 叶竞泽 on 2017/2/1.
//  Copyright © 2017年 JingZe. All rights reserved.
//

import UIKit


/// UIControl内置了TouchUpInside事件响应
class SSWBComposeTypeButton: UIControl {

    @IBOutlet weak var imageView: UIImageView!

    @IBOutlet weak var titleLabel: UILabel!
    
    /// 点击按钮要展示控制器的类名
    var clsName: String?
    
    /// 使用图像名称 / 标题创建按钮,从xib加载按钮
    ///
    /// - Parameters:
    ///   - imageName: 图像名称
    ///   - title: 文字
    /// - Returns: SSWBComposeTypeButton
    class func composeTypeButton(imageName: String, title: String) -> SSWBComposeTypeButton {
    
        guard let nib = UINib(nibName: "SSWBComposeTypeButton", bundle: nil).instantiate(withOwner: nil, options: nil).first as? SSWBComposeTypeButton, let image = UIImage(named: imageName) else {
            
            return SSWBComposeTypeButton()
        }
        
        nib.imageView.image = image
        nib.titleLabel.text = title
        
        return nib
    }
    
    
}
